using Provausio.Common.Objects;
using TrainingManagement.api.Models.BusinessObjects.Responses;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Employee;

namespace TrainingManagement.api.Models.BusinessLogic.Employee
{
    public class EmployeeUpdateOperation : BusinessOperation<BusinessObjects.Employee, GeneralResponse>
    {
        readonly EmployeeUpdateDataSource _employeeUpdate = new EmployeeUpdateDataSource();

        public override GeneralResponse Run(BusinessObjects.Employee input)
        {
            var response = new GeneralResponse();
            if (_employeeUpdate.Execute(input))
            {
                response.StatusCode = 200;
                response.Message = "Employee Updated.";
                return response;
            }

            response.StatusCode = 500;
            response.Message = "Employee was not updated.";
            return response;
        }
    }
}